//
//  WYJFViewController.m
//  WisdomCommunity
//
//  Created by Yahaong on 16/7/28.
//  Copyright © 2016年 zonten. All rights reserved.
//  物业缴费

#import "PropertycostsViewController.h"
#import "RoomListCell.h"
#import "PropertycostsSelectViewController.h"
#import "YHMarcros.h"

static NSString *const kRoomListCellReuseIdentifier = @"kRoomListCellReuseIdentifier";
@interface PropertycostsViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong)UITableView *roomListTableView;
/** 缴费记录 */
@property (nonatomic, strong)UIButton *IPRButton; //Individual Pay Record
/** 其他房产 */
@property (nonatomic, strong)UIButton *addButton;
@end

@implementation PropertycostsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kBgColor;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationItem.title = @"物业缴费";
    [self.view addSubview:self.roomListTableView];
    [self.roomListTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.equalTo(self.view);
        make.bottom.equalTo(self.view.bottom).offset(100);
    }];
    
    [self.view addSubview:self.IPRButton];
    [self.IPRButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(10);
        make.bottom.equalTo(self.view).offset(-60);
        make.height.equalTo(40);
        make.trailing.equalTo(self.view.centerX).offset(-10);
    }];
    
    [self.view addSubview:self.addButton];
    [self.addButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.IPRButton);
        make.trailing.equalTo(self.view).offset(-10);
        make.leading.equalTo(self.view.centerX).offset(10);
        make.height.equalTo(self.IPRButton);
    }];
    
}




- (UITableView *)roomListTableView
{
    if (!_roomListTableView) {
        _roomListTableView = [[UITableView alloc]init];
        _roomListTableView.backgroundColor = kBgColor;
        _roomListTableView.delegate = self;
        _roomListTableView.dataSource = self;
        [_roomListTableView registerClass:[RoomListCell class] forCellReuseIdentifier:kRoomListCellReuseIdentifier];
        _roomListTableView.rowHeight = 200;
        _roomListTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
    }
    return _roomListTableView;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{
   RoomListCell *cell =  [tableView dequeueReusableCellWithIdentifier:kRoomListCellReuseIdentifier];
    cell.block = ^(){
        
        PropertycostsSelectViewController *propertycostsSelectVc = [[PropertycostsSelectViewController alloc]init];
        [self.navigationController pushViewController:propertycostsSelectVc animated:YES];
    };
    return cell;
}




- (UIButton *)IPRButton
{
    if (!_IPRButton) {
        _IPRButton = [[UIButton alloc]init];
        [_IPRButton setTitle:@"缴费记录" forState:UIControlStateNormal];
        [_IPRButton setTitleColor:kGlobalRedColor forState:UIControlStateNormal];
        _IPRButton.backgroundColor = [UIColor whiteColor];
        _IPRButton.layer.cornerRadius = 10;
        _IPRButton.layer.masksToBounds = YES;
        _IPRButton.layer.borderWidth = 1;
        _IPRButton.layer.borderColor = kGlobalRedColor.CGColor;
    }
    return _IPRButton;
}

- (UIButton *)addButton
{
    if (!_addButton) {
        _addButton = [[UIButton alloc]init];
        [_addButton setTitle:@"其他房产" forState:UIControlStateNormal];
        _addButton.backgroundColor = kGlobalRedColor;
        _addButton.layer.cornerRadius = 10;
        _addButton.layer.masksToBounds = YES;
    }
    return _addButton;
}
@end
